package com.demo.quartz;

import org.quartz.*;

import java.util.Calendar;

public class MyJob2 implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        Calendar now = Calendar.getInstance();
        System.out.println(now.getTime());
        int num = (int) jobExecutionContext.getJobDetail().getJobDataMap().get("data");
        System.out.println("job2 start "+num);
//        try {
//            Thread.sleep(60000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        Scheduler scheduler = jobExecutionContext.getScheduler();
//        Calendar now = Calendar.getInstance();
//
//        System.out.println(now.getTime());
//        try {
//            List<JobExecutionContext> currentlyExecutingJobs = scheduler.getCurrentlyExecutingJobs();
//            for (JobExecutionContext jobContext: currentlyExecutingJobs)
//            {
//                /**
//                 * 当前job执行时间
//                 */
//                Date fireTime = jobContext.getFireTime();
//                System.out.println("-----------------job2 fireTime = "+fireTime);
//                /**
//                 * 前一个job 执行时间
//                 */
//                Date previousFireTime = jobContext.getPreviousFireTime();
//                System.out.println("*****************job2 previousFireTime = "+previousFireTime);
//
//                Trigger trigger = jobContext.getTrigger();
//                Scheduler scheduler1 = jobContext.getScheduler();
//                Trigger.TriggerState triggerState = scheduler1.getTriggerState(trigger.getKey());
//
//                System.out.println("######## job2 status is "+triggerState);
//            }
//
//        } catch (SchedulerException e) {
//            e.printStackTrace();
//        }
    }
}
